﻿using System;
using System.IO;
using Ninject;

namespace dse_pe_parser
{
    internal class Program
    {
        private static void Main(string[] args)
        {
            var kernel = new StandardKernel(new PeEngineModule());
            var provider = kernel.Get<IDailyPeRatiosProvider>();
            provider.Prepare();
            var list = provider.Fetch();

            File.WriteAllText("csvto.txt", list.ToCsv());
            File.WriteAllText("jsonto.txt", list.ToJson());
            File.WriteAllText("xmlto.txt", list.ToXml());
            File.WriteAllBytes("prototo.txt", list.ToProtobuf());

            var csv = PeRatiosList.FromCsv(File.ReadAllText("csvto.txt"), GlobalOptions.Instance.CsvHasHeader);
            File.WriteAllText("csvfm.txt", csv.ToCsv());

            var json = PeRatiosList.FromJson(File.ReadAllText("jsonto.txt"));
            File.WriteAllText("jsonfm.txt", json.ToJson());

            var xml = PeRatiosList.FromXml(File.ReadAllText("xmlto.txt"));
            File.WriteAllText("xmlfm.txt", xml.ToXml());

            var proto = PeRatiosList.FromProtobuf(File.ReadAllBytes("prototo.txt"));
            File.WriteAllBytes("protofm.txt", proto.ToProtobuf());
        }
    }
}